package account

import (
  "fmt"
  "gitee.com/yizhisamoye/GoWeChat/utils"
)
/**
链接转化
*/
func(w WxAccount)ShortUrl(longUrl string)(string,error){
  url:=fmt.Sprintf(BaseUrl+"/cgi-bin/shorturl?access_token=%s",w.accessToken)
  data:=map[string]string{
    "action":"long2short",
    "long_url":longUrl,
  }
  result,err:=utils.SendJson(url,data)
  if err!=nil{
    return "",err
  }
  shortUrl:=result["short_url"].(string)
  return shortUrl,nil
}
